Skip to content

Speed up merging the class lists in html_cva() recipes - #5035

Open
Kocal wants to merge 1 commit into
twigphp:3.xfrom
Kocal:perf/cva-apply-single-merge
Open

Kocal wants to merge 1 commit into
twigphp:3.xfrom
Kocal:perf/cva-apply-single-merge

Conversation

@Kocal

@Kocal Kocal commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Cva::apply() grew its class list with [...$classes, ...$more] for each recipe, compound variant and default variant, which copied the whole list each time.

It now collects the lists and merges them once with array_merge().

This is a small gain: 1218-1230 -> 1163-1173 ns per call on a button recipe with 3 variants, 3 sizes and 2 compound variants.

`Cva::apply()` grew its class list with `[...$classes, ...$more]` for each recipe, compound variant and default variant, which copied the whole list each time.

It now collects the lists and merges them once with `array_merge()`.

This is a small gain: 1218-1230 -> 1163-1173 ns per call on a button recipe with 3 variants, 3 sizes and 2 compound variants.
Comment thread CHANGELOG
* Add a way to mark a `Twig\Markup` instance as safe for some escaping strategies only
* Make `Environment::getExtension()` return the runtime of an extension class registered with `AttributeExtension`
* Make `Environment::getRuntime()` fall back to the registered extension of the same class
* Speed up merging the class lists in `html_cva()` recipes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in all similar PRs we can drop these lines IMHO

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We alreay have Speed up ... entries in the changelog, but on the other hand they produce conflicts every time after a merge... 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants